<?php
namespace clt;
use think\Cookie;
use think\Lang as MLang;
class Lang{
	public static function getLang(){
		$lang = null;
        $lang = request()->get('lang',null);
        if ($lang == null) {
            if (Cookie::has('cloud_var')) {
                $lang = Cookie::get('cloud_var');
            } else {
                $lang = config('default_lang');
            }
        }
        $allow_lang_list = config('allow_lang_list');  //语言列表
        $lang = strtolower($lang);
        if(!in_array($lang, $allow_lang_list)){
            $lang = config('default_lang');
        }
        $lang = MLang::range($lang);//设定当前语言
        Cookie::set('cloud_var', $lang);
        return $lang;
	}
}